import request from '@/utils/request'

export const getDemandList = (params) => {
  return request({
    url: '/demands',
    method: 'get',
    params
  })
}

export const getDemandDetail = (id) => {
  return request({
    url: `/demands/${id}`,
    method: 'get'
  })
}

export const createDemand = (data) => {
  return request({
    url: '/demands',
    method: 'post',
    data
  })
}

export const updateDemand = (id, data) => {
  return request({
    url: `/demands/${id}`,
    method: 'put',
    data
  })
}

export const deleteDemand = (id) => {
  return request({
    url: `/demands/${id}`,
    method: 'delete'
  })
}

export const applyDemand = (id, data) => {
  return request({
    url: `/demands/${id}/apply`,
    method: 'post',
    data
  })
}

export const assignDemand = (id, data) => {
  return request({
    url: `/demands/${id}/assign`,
    method: 'post',
    data
  })
}

export const completeDemand = (id) => {
  return request({
    url: `/demands/${id}/complete`,
    method: 'post'
  })
}

export const getDemandApplications = (id) => {
  return request({
    url: `/demands/${id}/applications`,
    method: 'get'
  })
}

export const getUserApplications = (userId) => {
  return request({
    url: `/demands/user/${userId}/applications`,
    method: 'get'
  })
}

